import random
def guess_quan():
    "这是一个猜拳游戏，三局两胜！"
    quan = ["石头","剪刀","布"]
    winlist = ["石头剪刀","剪刀布","布石头"]
    wincount = 0
    loscount = 0
    while True:
        pchoicenum =input("请输入您的猜拳： 0-石头 1-剪刀 2-布")
        if not pchoicenum in "012":
            continue
        pchoice = quan[int(pchoicenum)]
        robotchoice = random.choice(quan)

        if pchoice+robotchoice in winlist :
            print(f"您出的是{pchoice}，机器出的是{robotchoice},您赢了！")
            wincount += 1
        elif pchoice == robotchoice :
            print(f"您出的是{pchoice}，机器出的是{robotchoice},平局！")
        else:
            print(f"您出的是{pchoice}，机器出的是{robotchoice},您输了！")
            loscount += 1
        if wincount ==2:
            print("游戏结束，您赢了！")
            break
        if loscount == 2:
            print("游戏结束，您输了！")
            break
def guessnum():
    "这是一个猜数字游戏，用户猜对机器随机产生的数字，只有10次猜测机会，猜对即结束"
    robornum = random.randint(1,1000)
    count = 10
    while True:
        print("----猜数字游戏开始----")
        print(f"----您还有 {count} 猜测机会----")
        personnum = int(input("请输入一个数字（1-1000）:"))
        if personnum >robornum :
            print("您猜大了！")
        elif personnum < robornum :
            print("您猜小了！")
        else:
            print("您猜对了！")
            break
        count -= 1
        if count ==0 :
            print("很遗憾，次数用尽，您没猜对！")
            break
if __name__ == "__main__" :
    guess_quan()
    guessnum()